﻿using UnityEngine;
using System.Collections;

using UEngine;

public class ComplexParam
{
    public int   iParam;
    public float fParam;
}

public class TestGameEvent : MonoBehaviour 
{

	// Use this for initialization
    GameEventManager m_gameEventManager = null;
    void Awake()
    {
        m_gameEventManager = GameEventManager.Instance();
    }
	void Start () 
    {
        m_gameEventManager.RegisteHandle(1, EventHandle_1_1);
        m_gameEventManager.RegisteHandle(1, EventHandle_1_2);
        //m_gameEventManager.UnRegister(1, EventHandle_1_1);
        m_gameEventManager.PushEvent(1);

        m_gameEventManager.RegisteHandle(2, EventHandle_2_1);
        int n = 100;
        m_gameEventManager.PushEvent(2, n);

        m_gameEventManager.RegisteHandle(3, EventHandle_3_1);
        ComplexParam cp = new ComplexParam();
        cp.fParam = 23.3f;
        cp.iParam = 25;
        m_gameEventManager.PushEvent(3, cp);
	}
	void Update () 
    {
        m_gameEventManager.Update();
	}

    void EventHandle_1_1(GameEventParam param)
    {
        Debug.Log("EventHandle_1_1");
    }

    void EventHandle_1_2(GameEventParam param)
    {
        Debug.Log("EventHandle_1_2");
    }

    void EventHandle_2_1(GameEventParam param)
    {
        int n = (int)param.data;
        Debug.Log("EventHandle_2_1 : " + n);
    }

    void EventHandle_3_1(GameEventParam param)
    {
        ComplexParam cp = (ComplexParam)param.data;
        Debug.Log("EventHandle_3_1 : " + cp.iParam + ", " + cp.fParam);
    }
}
